
Imports System.Data.SqlClient

Public Class Operacion2

  
    Public Function CuentaRegistros2() As Integer

        StringComando2 = "SELECT COUNT (*) FROM cuenta2"
        Dim Conecta2 As New SqlConnection(StringConecta2)
        Conecta2.Open()
        Comando2 = New SqlCommand(StringComando2, Conecta2)
        Adapter2 = New SqlDataAdapter(StringComando2, Conecta2)
        Ds2 = New DataSet
        Adapter2.Fill(Ds2, "REGISTRO2")
        Dim RegistrosCuenta2 As Integer = Ds2.Tables(0).Rows(0).Item(0)

        Conecta2.Close()
        Conecta2.Dispose()

        Return RegistrosCuenta2

    End Function

    Public Function CopiarRegistro(ByVal registro As Registro) As Boolean

        Try

            Dim Cuenta As Integer = registro.Cuenta
            Dim Importe As String = registro.Importe.ToString.Replace(",", ".")

            StringComando2 = "INSERT INTO CUENTA2 (CUENTA, IMPORTE) VALUES ( "
            StringComando2 += Cuenta & " , " & Importe & " )"

            Dim Conecta2 As New SqlConnection(StringConecta2)
            Conecta2.Open()
            Comando2 = New SqlCommand(StringComando2, Conecta2)
            Comando2.ExecuteNonQuery()

            Conecta2.Close()
            Conecta2.Dispose()

            Return True

        Catch ex As Exception

            MsgBox(ex.ToString)
            Return False

        End Try

    End Function

End Class
